<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
	<section class="content"> 
       <div class="row">
       		<div class="col-xs-12">
	       		<div class="box"> 
	           	<div class="box-header">
	               <nav class="navbar navbar-default">	     
				        <div class="collapse navbar-collapse">
				          <form class="navbar-form form-inline" action="{:U('Promotion/huodongguolv')}" method="get">
				            <div class="form-group">
				              	<input type="text" name="keywords" id="keywords" class="form-control" style="width:300px;" placeholder="过滤关键词,如:铁钉,铁线,焊材.." value="{$keywords}">
				            </div>
							<div class="form-group">
							    <div class="input-group">
							        <input type="text" name="timegap" value="{$timegap}" placeholder="下单日期"  id="add_time" class="input-sm" style="width: 220px;">
							     </div>
							</div>
				            <button type="submit" class="btn btn-default">提交</button>
							<button type="button" class="btn btn-default pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>
				          </form>
				      	</div>
	    			</nav>                
	             </div>	    
	             <!-- /.box-header -->
	             <div class="box-body">	             
	           		<div class="row">
	            	<div class="col-sm-12">
		              <table id="list-table" class="table table-bordered table-striped dataTable">
		                 <thead>
		                   <tr role="row">
							   <th class="sorting" style="text-align:center" tabindex="0">分部</th>
			                   <th class="sorting" style="text-align:center" tabindex="0">线路</th>
			                   <th class="sorting" style="text-align:center" tabindex="0">下单客户</th>
							   <th class="sorting" style="text-align:center" tabindex="0">客户电话</th>
			                   <th class="sorting" style="text-align:center" tabindex="0">消费金额</th>
			                   <th class="sorting" style="text-align:center" tabindex="0">下单时间</th>
		                   </tr>
		                 </thead>
						<tbody>
						<?php
						foreach($data as $vs){
								echo '<tr role="row" align="center">
										<td>'.$vs['fenbu_name'].'</td>
										<td>'.$vs['biaoshi_xian'].'</td>
										<td>'.$vs['company'].'</td>
										<td>'.$vs['mobile'].'</td>
										<td style="color:red;">'.$vs['order_amount'].'</td>
										<td>'.$timegap.'</td>
										</tr>';
								}
						?>
		                   </tbody>
		               </table>
	               </div>
	          </div>
	          </div><!-- /.box-body -->
	        </div><!-- /.box -->
       	</div>
       </div>
   </section>
</div>
<script>
		$('#add_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
	        showWeekNumbers: true,
	        timePicker: true,
	        timePickerIncrement: 1,
	        timePicker12Hour: false,
	        opens: 'right',
	        buttonClasses: ['btn btn-default'],
	        applyClass: 'btn-small btn-primary',
	        cancelClass: 'btn-small',
		    locale : {
	            applyLabel : '确定',
	            cancelLabel : '取消',
	            fromLabel : '起始时间',
	            toLabel : '结束时间',
	            customRangeLabel : '自定义',
	            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
	            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
	            firstDay : 1
	        }
		});

	$("#daochu").click(function(){
		var keywords=$("#keywords").val();
		var timegap=$("#add_time").val();
		location.href="/Admin/Promotion/huodongguolv?keywords="+keywords+"&timegap="+timegap+"&action=daochu";
	})
	
$('.goods_list').click(function(){
    var url = $(this).attr('data-url');
    layer.open({
        type: 2,
        title: '活动关联商品列表',
        shadeClose: true,
        shade: 0.5,
        area: ['70%', '72%'],
        content: url, 
    });
});

function changeStatus(status,id,tab){
	if(status>1){
    	layer.confirm('确认删除？', {btn: ['确定','取消']}, function(){
	  			$.ajax({
	  				type : 'GET',
	  				url : "{:U('Promotion/activity_handle')}",
	  				data : {'id':id,'tab':tab,'status':status},
	  				dataType :'JSON',
	  				success : function(res){
	  					if(res == 1){
	  						layer.msg('操作成功', {icon: 1});
	  						window.location.reload();
	  					}else{
	  						layer.msg('操作失败', {icon: 2,time: 2000});
	  					}
	  					layer.closeAll();
	  				}
	  			});
  			}, function(index){
  				layer.close(index);
  				return false;// 取消
  			});
	}else{
		$.ajax({
			type : 'GET',
			url : "{:U('Promotion/activity_handle')}",
			data : {'id':id,'tab':tab,'status':status},
			dataType :'JSON',
			success : function(res){
				if(res == 1){
					layer.msg('操作成功', {icon: 1});
					window.location.reload();
				}else{
					layer.msg('操作失败', {icon: 2,time: 2000});
				}
				layer.closeAll();
			}
		});
	}
}
</script>
</body>
</html>